package com.quanshi.cloudmeeting.ci.assistant;

import java.io.File;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Scanner;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;

public class Qrcode {

	public static void main(String[] args) throws Exception {
		String url = args[0];
		String filepath = args[1];
		Qrcode qrcode = new Qrcode();
		qrcode.MakeImage(url, filepath);

	}

	
	public void MakeImage(String urlString, String filepath) throws WriterException,
			IOException {
		// String url = "http://www.baidu.com";
		int width = 300;
		int height = 300;
		//
		String format = "jpg";
		Hashtable hints = new Hashtable();
		//
		hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
		BitMatrix bitMatrix = new MultiFormatWriter().encode(urlString,
				BarcodeFormat.QR_CODE, width, height, hints);

		//
		File outputFile = new File(filepath);
		ImageWriter.writeToFile(bitMatrix, format, outputFile);
	}

	
	
}
